Skip to content

feat: support uv-managed Python Actors in apify create#1274

Open
vdusek wants to merge 1 commit into
masterfrom
feat/create-uv-support
Open

feat: support uv-managed Python Actors in apify create#1274
vdusek wants to merge 1 commit into
masterfrom
feat/create-uv-support

Conversation

@vdusek

@vdusek vdusek commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

apify create hard-coded pip install -r requirements.txt for Python Actors, so creating a uv-managed template — which ships pyproject.toml + uv.lock and no requirements.txt — failed during dependency install with Could not open requirements file.

create now detects uv-managed Python/Scrapy projects by the presence of a committed uv.lock and installs their dependencies with uv sync instead. The check runs before the system-Python detection, since uv provides the interpreter pinned in .python-version itself, and falls back to a warning with install instructions when the uv executable isn't found.

This unblocks the upcoming python-uv template (apify/actor-templates#800).

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jul 10, 2026
@vdusek vdusek self-assigned this Jul 10, 2026
@vdusek vdusek marked this pull request as ready for review July 13, 2026 08:28
@vdusek vdusek requested review from DaveHanns and l2ysho as code owners July 13, 2026 08:28

@l2ysho l2ysho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine 🚀 . Added some questions and nits. Only thing worth of attention is https://github.com/apify/apify-cli/pull/1274/changes#r3586664002 but it is non-blocking.
also it would be fine to ad some tests (at least happy path).

Comment thread src/commands/create.ts
Comment on lines +216 to +219
'This Actor uses uv to manage its dependencies, but the uv executable was not found. ' +
'Install uv (https://docs.astral.sh/uv/getting-started/installation/), then run "uv sync" in the Actor directory.',
});
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: we should check for uvPath also in getInstallCommandSuggestion otherwise we recommend pip install after this warning (or after --skip-dependency-install)

something like this maybe 🔽 ?

} else if (project.type === ProjectLanguage.Python || project.type === ProjectLanguage.Scrapy) {
    const hasUvLock = await stat(join(actFolderDir, 'uv.lock')).then(() => true).catch(() => false);
    installCommandSuggestion = hasUvLock ? 'uv sync' : 'python -m pip install -r requirements.txt';
}

Comment thread src/commands/create.ts
Comment on lines +224 to +228
await execWithLog({
cmd: uvPath,
args: ['sync'],
opts: { cwd: actFolderDir },
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: "pip way" now ignores skipOptionalDeps flag, is this the same for uv? does uv have something for optional deps?

Comment thread src/commands/create.ts
Comment on lines +206 to +208
const hasUvLock = await stat(join(actFolderDir, 'uv.lock'))
.then(() => true)
.catch(() => false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: now we run it also for javascript projects, maybe we can move it to isPythonProject code block?

Comment thread src/commands/create.ts
// environment, dependencies, and Python version. Install them with `uv sync` instead of the
// pip + requirements.txt flow. uv provides the Python pinned in `.python-version` on its own,
// so this runs even when no system Python is detected.
const isPythonProject = project.type === ProjectLanguage.Python || project.type === ProjectLanguage.Scrapy;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: does it make sense to introduce new parameters in project level so we do not need to check for uv.lock? Or make uv part of project.packageManager?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants